package com.baselibrary.adapter

import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import com.baselibrary.Constants
import com.baselibrary.R
import com.baselibrary.extension.checkValue
import com.baselibrary.utils.CommonUtil
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.baselibrary.bean.OrderBottomItemBean

/**
 * 订单编号                xxxx
 */
class OrderBottomItemAdapter(data: List<OrderBottomItemBean>) : BaseMultiItemQuickAdapter<OrderBottomItemBean, BaseViewHolder>(data) {

    init {
        addItemType(Constants.TYPE_HAVE_BUTTON, R.layout.item_order_bottom_have_button)
        addItemType(Constants.TYPE_TXT, R.layout.item_order_bottom_have_button)
        addItemType(Constants.TYPE_EDIT, R.layout.item_order_bottom_edit_text)
    }

    override fun convert(helper: BaseViewHolder, item: OrderBottomItemBean) {
        helper.setText(R.id.tv_title, item.leftTitle.checkValue())
        helper.getView<ImageView>(R.id.img_copy).setOnClickListener {
            CommonUtil.contentClipboard(mContext, item.rightContent.checkValue(), "复制成功")
        }
        when (item.itemType) {
            Constants.TYPE_HAVE_BUTTON -> {
                //带复制按钮
                helper.setGone(R.id.img_copy, true)
                helper.setText(R.id.tv_right_content, item.rightContent.checkValue())
            }
            Constants.TYPE_TXT -> {//纯文本
                helper.setGone(R.id.img_copy, false)
                helper.setText(R.id.tv_right_content, item.rightContent.checkValue())
            }
            Constants.TYPE_EDIT -> {// 带输入框
                helper.setGone(R.id.img_copy, false)
                helper.getView<EditText>(R.id.et_input).setHint(item.rightContent.checkValue())
            }
        }
    }
}